<template>
	<view class="page">
		<view class="my_padding">
			<view class="news_part">
				<view v-for="(item,index) in newsList" @click="navToUrl('/pages/news/detail?news_id='+item.id)" class="newlist margin-tb-lg  "  >
					<view class="new_list_img">
						<image   :src="weburl+item.photo" mode=""></image>
					</view>
					<view class="new_cont_text" >
						<view class="title" >
							{{ item.title }} 
						</view>
						<view class="cont"  >
							 《{{ item.keyword }}》  
						</view>
					</view>
					 
				</view>
			</view>
		</view>
	</view>
</template>

<script>

	export default {
		components: {

		},
		data() {
			return {
				tabCurrentIndex: 0, //当前选项卡索引
				scrollLeft: 0, //顶部选项卡左滑距离
				enableScroll: true,
				tabBars: [],
				newsList:[],
				page: 1,
			};
		},
		onLoad() {
			this.loadNewsList();
		},		
		onHide() {
			this.ifOnShow = true
		},
		onShow() {
			let pages = getCurrentPages();
			let currPage = pages[pages.length-1];
			if (currPage.$vm.bank_id){
				this.bank_id = currPage.$vm.bank_id;
				// this.loadData();
			}
		},
		
		methods: {
			//user数据
			getData: function() {
				var info = uni.getStorageSync("userinfo");
				if (info.token) {
					let timestamp = this.helper.now();
					let sign = this.helper.setSign(['username=' + info.username, 'token=' + info.token, 'timestamp=' +
						timestamp
					]);
					this.helper.req({
						api: "getUserInfo",
						timestamp: timestamp,
						data: {
							username: info.username,
							token: info.token
						},
						header: {
							sign: sign
						},
						method: 'GET',
					}).then(res => {
						// console.log('userInfo参数:', this.userinfo)
						
					})
				} else {
					uni.hideLoading();
				}
			},
		
			//新闻列表
			loadNewsList(){
				let timestamp = this.helper.now();
				let sign = this.helper.setSign(['type=1001','page='+this.page,'timestamp='+timestamp]);
				this.helper.req({
					api:"getNewsList",
					timestamp:timestamp,
					data:{type:1001,page:this.page},
					header:{sign:sign},
					method:'GET',
				}).then(res=>{
					console.log('新闻',res.data.data.lista)
					let current_page = res.data.data.lista.current_page;
					let last_page = res.data.data.lista.last_page;
					if(current_page == last_page){
						this.loadMoreStatus = 2;
					}else{
						this.page = current_page + 1;
					}
					this.lastPage = last_page;
					this.newsList = this.newsList.concat(res.data.data.lista);
					console.log('新闻',this.newsList)
				})
			},
			navToUrl: function(url) {
				return uni.navigateTo({
					url: url
				});
			},
			imageError: function(e) {
				this.avatar = '/static/icon_avatar.png';
			},
			confirmHandler() {
				// 处理确认按钮点击事件
				console.log('确认按钮点击了')
			},
			showDialog(){
				this.toggleMessage()
			},
			toggleMessage() {
				this.$refs.popupDialog.open()
			},
		},
	};
</script>

<style lang="scss">
	page {
		background-color: #dceafb;
	}
	
	.my_padding {

	}
	.news_part{
		color: #fff;
		background-color: #fff;
		margin: 40rpx;
		border-radius: 20rpx;
		.newlist{
			margin: 0 10rpx;
			border-bottom: 1px solid #9c9c9c;
			padding: 20rpx ;
			display: flex;
			align-items: center;
			
			.new_list_img{
				width: 252rpx;
				height: 156rpx;
				border-radius: 20rpx;
				overflow: hidden;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.new_cont_text{
				width: 330rpx;
				margin-left: 35rpx;
				.title{
					color: #4188ff;
					font-size: 30rpx;
					font-weight: bold;
					width: 100%;
					word-break: break-all;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
					  
				}
				.cont{
					color: #353535;
					font-size: 25rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
	.news_active{
		height: 50vw;
		padding: 10px;
		width: 94vw;
		background: #fff;
		margin: 3vw;
		border-radius: 8px;
		position: relative;
	}
	.active{
		position: absolute;
		top: 10px;
		left: 10px;
		line-height: 24px;
		padding: 2px 10px;
		font-size: 14px;
		border:1px solid #d4244e;
		color:#d4244e;
		border-radius:6px;
	}
	.new_tit{
		position: absolute;
		top: 40px;
		left: 10px;
		width: 280px;
		line-height: 40px;
		font-weight: bold;
		font-size: 16px;
	}
	.new_date{
		position: absolute;
		top: 80px;
		left: 10px;
		width: 200px;
		height: 30px;
		line-height: 20px;
		font-size: 14px;
		color:#999;
	}
	.new_contain{
		position: absolute;
		top: 130px;
		left: 10px;
		width: 340px;
		height: 30px;
		line-height: 20px;
		font-size: 15px;
		padding: 10px;
		color:#666;
	}
	
	.zx_tit{
		line-height: 30px;
		padding: 10px 0 0;
		font-size: 16px;
		font-weight: bold;
		width: 96vw;
		margin-left: 3vw;
		text-align: center;
	}
	.zx_list{
		// height: 50vw;
		padding: 10px;
		width: 94vw;
		background: #fff;
		margin: 3vw;
		border-radius: 8px;
	}
	.zx_item{
		height: 20vw;
		width: 100%;
		border-bottom: 0.5px solid #EEE;
	}
	.zx_item image{
		width: 20vw;
		height: 20vw;
		float: left;
	}
	.zx_contain{
		width: 66vw;
		height: 20vw;
		line-height: 24px;
		padding: 10px 6px;
		font-size: 15px;
		float: left;
	}
	
	.inviteRecode{
		line-height: 30px;
		padding: 6px 0;
		height: 42px;
		width: 60%;
		position: absolute;
		bottom: -20px;
		left: 20%;
		color:#fff;
		background-color: #fea829;
		font-size: 14px;
		text-align: center;
		border-radius: 8px;
	}
	
	.invite_now{
		line-height: 30px;
		padding: 6px 0;
		height: 42px;
		width: 100%;
		position: absolute;
		bottom: 0;
		left: 0;
		color:#fff;
		background-color: #fea829;
		font-size: 14px;
		text-align: center;
	}
	
	.invite_img{
		width: 40px;
		height: 40px;
	}
	.grid-item-box text{
		line-height: 20px;
		display: inherit;
		font-size: 14px; 
		color:#333;
	}
	
	.newuser{
		min-height: 800px;
		position: relative;
	}
	
	.invite_regular{
		position: absolute;
		top: 360px;
		left:4%;
		width: 92%;
		height: 200px;
		color: #fff;
		font-size: 14px;
	}
	.regular_tit{
		font-size: 15px;
		font-weight: bold;
		line-height: 30px;
	}
	.regular_contain p{
		font-size: 14px;
	}
	
	.checkTeam{
		position: fixed;
		top: 56px;
		right: 0;
		padding: 6px 10px 6px 16px;
		line-height: 20px;
		font-size: 16px;
		background: #fea829;
		color:#fff;
		border-radius:16px 0 0 16px;
	}

</style>
